//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Internals;

namespace OpenLS.Spreadsheet.Drawing
{
    class Marker: IOfficeXmlSerializableAs
    {
        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (ReadContext c = context.Read(name))
            {
                c.PassAttributes();
                Column = int.Parse(context.ReadElementString("col"));
                ColumnOffset = EmuConverter.FromEmu(int.Parse(context.ReadElementString("colOff")));
                Row = int.Parse(context.ReadElementString("row"));
                RowOffset = EmuConverter.FromEmu(int.Parse(context.ReadElementString("rowOff")));
            }
        }

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                c.WriteElementString("col", Column.ToString());
                c.WriteElementString("colOff", EmuConverter.ToEmu(columnOffset).ToString());
                c.WriteElementString("row", Row.ToString());
                c.WriteElementString("rowOff", EmuConverter.ToEmu(rowOffset).ToString());
            }
        }

        #endregion
        private int column;

        public int Column
        {
            get { return column; }
            set { column = value; }
        }
        private int row;

        public int Row
        {
            get { return row; }
            set { row = value; }
        }

        private double rowOffset;

        public double RowOffset
        {
            get { return rowOffset; }
            set { rowOffset = value; }
        }
        private double columnOffset;

        public double ColumnOffset
        {
            get { return columnOffset; }
            set { columnOffset = value; }
        }
    }
}
